package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import net.wanho.R.R;
import net.wanho.service.FileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
public class FileController {

    private final FileService fileService;

    // 文件上传
    @SneakyThrows
    @PostMapping("/upload")
    public R upload(MultipartFile file) {
        String url = fileService.uploadFile(file);
        return R.ok("文件上传成功！", url);
    }
}
